﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Diagnostics;
using System.ComponentModel;
using WPFExcelReport.Helpers;
using System.Windows.Input;
namespace WPFExcelReport
{
    public partial class TSBS07
    {
        public TSBS07()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VBSFARB();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void OnEXAUFChg(string vlaue)
        {
            if (EXAUF.Length < 22)
                return;
            dwData = TBMain.NewRow();
            dwData["BSFMANDANT"] = app.Mandant;
            dwData["BSFKART"] = " AND BSFKART='" + EXAUF.Substring(1, 20) + "'";
            dwData["BSFKVAR"] = " AND BSFKVAR='" + EXAUF.Substring(21, 2) + "'";
            SResult = TMV.QBSF03(dwData);
            MergeData(SResult, false);
            base.OnEXAUFChg(vlaue);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            vwMaster.View.MoveCurrentTo(-1);
        }
        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length < 32)
                return;
            dwData = TBMain.NewRow();
            dwData["BSFMANDANT"] = app.Mandant;
            dwData["BSFKART"] = EXAUF.Substring(1, 20);
            dwData["BSFKVAR"] = EXAUF.Substring(21, 2);
            dwData["BSFKFARBE"] = EXAUF.Substring(33, 10); 
            SResult = TMV.QBSF01(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        }
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnEXAUFChg(EXAUF);
            }
            else
            {
                VICC_WFEVENTS.SVWF.UBS07(RUNID, KEY);

            }
            base.ManageCommand(sender, e);
        }

    }
}
